package com.bjsxt.thread;

public class priorityThread {
    public static void main(String[] args) {
        Thread p1 =new Thread(new Priority(),"线程1");
        Thread p2 =new Thread(new Priority(),"线程2");
        p1.setPriority(Thread.MIN_PRIORITY);
        p2.setPriority(Thread.MAX_PRIORITY);
        p1.start();
        p2.start();
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        p1.stop();
        p2.stop();
    }
}

class Priority implements Runnable{
    private int num =0;
    private boolean flag =true;
    @Override
    public void run() {
        while (this.flag){
            System.out.println(Thread.currentThread().getName()+" "+ num++);
        }
    }
    public void stop(){
        this.flag=false;
    }
}